﻿using System;
using System.Xml;

namespace MVCFoto.BLL
{
    public class XmlHelper
    {
        /// <summary>
        /// 取得节点的内容
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static string GetNodeValue(XmlNode n)
        {
            if (n == null || n.FirstChild == null)
                return string.Empty;
            return n.FirstChild.Value;
        }
        /// <summary>
        /// 取得节点的指定的属性值
        /// </summary>
        /// <param name="n"></param>
        /// <param name="attribute">属性名</param>
        /// <returns></returns>
        public static string GetNodeAttributeValue(XmlNode n,string attribute)
        {
            if (n.Attributes.GetNamedItem(attribute) == null || String.IsNullOrEmpty(n.Attributes.GetNamedItem(attribute).Value))
                return string.Empty;
            else
                return n.Attributes.GetNamedItem(attribute).Value;
        }
    }
}
